package com.example.demo.controller;

import ch.qos.logback.core.util.StringUtil;
import jakarta.servlet.http.HttpSession;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/user")
public class UserController {
    @RequestMapping("/login")
    public Boolean login(String name, String password, HttpSession session){
        if(StringUtil.isNullOrEmpty(name)||StringUtil.isNullOrEmpty(password)){
            return false;
        }
        //校验账号密码是否正确
        //TODO 暂且硬编码
        if("admin".equals(name)&&"admin".equals(password)){
            session.setAttribute("name",name);
            return true;
        }
        return false;
    }
}
